
package komunikaty;

import java.io.Serializable;
import java.math.BigInteger;
import java.util.Random;


//struktura karty
public class Card implements Serializable{


    //pojedynczy glos
    public class Vote implements Serializable{
        public BigInteger candidate;
        public BigInteger serial;
        public Vote(BigInteger serial, BigInteger candidate)
        {
            this.candidate=candidate;
            this.serial=serial;
        }
    }
    
    private static Random rand = new Random();
    public Vote[] votes;

    public Card(BigInteger[] candidateList) {
        votes = new Vote[candidateList.length];

        BigInteger serial = new BigInteger(80, rand);
        int i = 0;
        for (BigInteger s : candidateList) {
            votes[i++]=new Vote(new BigInteger(serial.toString()),s);
            
        }
    }

    
    @Override
    public String toString(){
        String str = "";
        for (int i = 0; i < votes.length; i++) {
            Card.Vote vote = votes[i];
            str += vote.candidate.toString()+" "+vote.serial.toString()+"\n";
        }
        return str;
    }
}
